<?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) die('Access Denied');
if(!($maxfileuploads=ini_get('max_file_uploads')))
    $maxfileuploads=DEFAULT_MAX_FILE_UPLOADS;
?>
<h2><?php echo $trl->translate('T_1')?></h2>
<form action="settings.php?t=tickets" method="post" id="save">
<?php csrf_token(); ?>
<input type="hidden" name="t" value="tickets" >
<table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
    <thead>
        <tr>
            <th colspan="2">
                <?php echo $trl->translate('T_2')?>
            </th>
        </tr>
    </thead>
    <tbody>
        <tr><td width="220" class="required"><?php echo $trl->translate('T_3')?>:</td>
            <td>
                <input type="radio" name="random_ticket_ids"  value="0" <?php echo !$config['random_ticket_ids']?'checked="checked"':''; ?> />
                <?php echo $trl->translate('T_4')?>
                <input type="radio" name="random_ticket_ids"  value="1" <?php echo $config['random_ticket_ids']?'checked="checked"':''; ?> />
                <?php echo $trl->translate('T_5')?>
            </td>
        </tr>

        <tr>
            <td width="180" class="required">
                <?php echo $trl->translate('T_6')?>:
            </td>
            <td>
                <select name="default_sla_id">
                    <option value="0">&mdash; 请选择 &mdash;</option>
                    <?php
                    $sql='SELECT id,name FROM '.SLA_TABLE.' sla ORDER by name';
                    if(($res=db_query($sql)) && db_num_rows($res)){
                        while(list($id,$name)=db_fetch_row($res)){
                            $selected=($config['default_sla_id'] && $id==$config['default_sla_id'])?'selected="selected"':'';
                            echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
                        }
                    }
                    ?>
                </select>
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['default_sla_id']; ?></span>
            </td>
        </tr>
        <tr>
            <td width="180" class="required"><?php echo $trl->translate('T_7')?>:</td>
            <td>
                <select name="default_priority_id">
                    <?php
                    $priorities= db_query('SELECT priority_id,priority_desc FROM '.TICKET_PRIORITY_TABLE);
                    while (list($id,$tag) = db_fetch_row($priorities)){ ?>
                        <option value="<?php echo $id; ?>"<?php echo ($config['default_priority_id']==$id)?'selected':''; ?>><?php echo $tag; ?></option>
                    <?php
                    } ?>
                </select>
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['default_priority_id']; ?></span>
             </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_8')?>:</td>
            <td>
                <input type="text" name="max_open_tickets" size=4 value="<?php echo $config['max_open_tickets']; ?>">
                <?php echo $trl->translate('T_9')?>
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_10')?>:</td>
            <td>
                <input type="text" name="autolock_minutes" size=4 value="<?php echo $config['autolock_minutes']; ?>">
                <font class="error"><?php echo $errors['autolock_minutes']; ?></font>
                <em>(<?php echo $trl->translate('T_11')?>)</em>
            </td>
        </tr>
        <tr>
                    <td width="180"><?php echo $trl->translate('T_12')?>:</td>
                    <td>
                        <input type="checkbox" name="allow_priority_change" value="1" <?php echo $config['allow_priority_change'] ?'checked="checked"':''; ?>>
                        <em>(<?php echo $trl->translate('T_13')?>)</em>
                    </td>
                </tr>
                <tr>
                    <td width="180"><?php echo $trl->translate('T_14')?>:</td>
                    <td>
                        <input type="checkbox" name="use_email_priority" value="1" <?php echo $config['use_email_priority'] ?'checked="checked"':''; ?> >
                        <em>(<?php echo $trl->translate('T_15')?>)</em>
            </td>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_16')?>:</td>
            <td>
                <input type="checkbox" name="show_related_tickets" value="1" <?php echo $config['show_related_tickets'] ?'checked="checked"':''; ?> >
                <em>(<?php echo $trl->translate('T_17')?>)</em>
            </td>
        </tr>        
        <tr>
            <td width="180"><?php echo $trl->translate('T_18')?>:</td>
            <td>
                <input type="checkbox" name="show_notes_inline" value="1" <?php echo $config['show_notes_inline'] ?'checked="checked"':''; ?> >
                <em>(<?php echo $trl->translate('T_19')?>)</em>
              </td>
        </tr>
        <tr><td><?php echo $trl->translate('T_20')?>:</td>
            <td>
              <input type="checkbox" name="clickable_urls" <?php echo $config['clickable_urls']?'checked="checked"':''; ?>>
               <em>(<?php echo $trl->translate('T_21')?>)</em>
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_22')?>:</td>
            <td>
                <input type="checkbox" name="enable_captcha" <?php echo $config['enable_captcha']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_23')?> &nbsp;<font class="error">&nbsp;<?php echo $errors['enable_captcha']; ?></font><br/>
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_24')?>:</td>
            <td>
                <input type="checkbox" name="auto_assign_reopened_tickets" <?php echo $config['auto_assign_reopened_tickets']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_25')?>.
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_26')?>:</td>
            <td>
                <input type="checkbox" name="show_assigned_tickets" <?php echo $config['show_assigned_tickets']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_27')?>.
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_28')?>:</td>
            <td>
                <input type="checkbox" name="show_answered_tickets" <?php echo $config['show_answered_tickets']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_29')?>.
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_30')?>:</td>
            <td>
                <input type="checkbox" name="log_ticket_activity" <?php echo $config['log_ticket_activity']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_31')?>.
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_32')?>:</td>
            <td>
                <input type="checkbox" name="hide_staff_name" <?php echo $config['hide_staff_name']?'checked="checked"':''; ?>>
                <?php echo $trl->translate('T_33')?>.
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <?php echo $trl->translate('T_34')?>
            </th>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_35')?>:</td>
            <td>
              <input type="checkbox" name="allow_attachments" <?php echo $config['allow_attachments']?'checked="checked"':''; ?>>
                &nbsp; <?php echo $trl->translate('T_36')?>
                &nbsp;<font class="error">&nbsp;<?php echo $errors['allow_attachments']; ?></font>
            </td>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_37')?>:</td>
            <td>
                <input type="checkbox" name="allow_email_attachments" <?php echo $config['allow_email_attachments']?'checked="checked"':''; ?>> <?php echo $trl->translate('T_38')?>
                    &nbsp;<font class="error">&nbsp;<?php echo $errors['allow_email_attachments']; ?></font>
            </td>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_39')?>:</td>
            <td>
                <input type="checkbox" name="allow_online_attachments" <?php echo $config['allow_online_attachments']?'checked="checked"':''; ?> >
                    <?php echo $trl->translate('T_40')?> &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="allow_online_attachments_onlogin" <?php echo $config['allow_online_attachments_onlogin'] ?'checked="checked"':''; ?> >
                    <?php echo $trl->translate('T_41')?>
                    <font class="error">&nbsp;<?php echo $errors['allow_online_attachments']; ?></font>
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_42')?>:</td>
            <td>
                <select name="max_user_file_uploads">
                    <?php
                    for($i = 1; $i <=$maxfileuploads; $i++) {
                        ?>
                        <option <?php echo $config['max_user_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>">
                            <?php echo $i; ?>&nbsp;<?php echo ($i>1)?'个文件':'个文件'; ?></option>
                        <?php
                    } ?>
                </select>
                <?php echo $trl->translate('T_43')?>
                &nbsp;<font class="error">&nbsp;<?php echo $errors['max_user_file_uploads']; ?></font>
            </td>
        </tr>
        <tr>
            <td><?php echo $trl->translate('T_44')?>:</td>
            <td>
                <select name="max_staff_file_uploads">
                    <?php
                    for($i = 1; $i <=$maxfileuploads; $i++) {
                        ?>
                        <option <?php echo $config['max_staff_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>">
                            <?php echo $i; ?>&nbsp;<?php echo ($i>1)?'个文件':'个文件'; ?></option>
                        <?php
                    } ?>
                </select>
                <?php echo $trl->translate('T_45')?>
                &nbsp;<font class="error">&nbsp;<?php echo $errors['max_staff_file_uploads']; ?></font>
            </td>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_46')?>:</td>
            <td>
                <input type="text" name="max_file_size" value="<?php echo $config['max_file_size']; ?>"> <?php echo $trl->translate('T_47')?>.
                    <em>(<?php echo $trl->translate('T_48')?>. <?php echo Format::file_size(ini_get('upload_max_filesize')); ?>)</em>
                    <font class="error">&nbsp;<?php echo $errors['max_file_size']; ?></font>
            </td>
        </tr>
        <tr>
            <td width="180"><?php echo $trl->translate('T_49')?>:</td>
            <td>
                <input type="checkbox" name="email_attachments" <?php echo $config['email_attachments']?'checked="checked"':''; ?> ><?php echo $trl->translate('T_50')?>
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <em><?php echo $trl->translate('T_51')?>.
                <font class="error">&nbsp;<?php echo $errors['allowed_filetypes']; ?></font></em>
            </th>
        </tr>
        <tr>
            <td colspan="2">
                <?php echo $trl->translate('T_52')?><br>
                <textarea name="allowed_filetypes" cols="21" rows="4" style="width: 65%;" wrap="hard" ><?php echo $config['allowed_filetypes']; ?></textarea>
            </td>
        </tr>
    </tbody>
</table>
<p style="padding-left:250px;">
    <input class="button" type="submit" name="submit" value="<?php echo $trl->translate('T_53')?>">
    <input class="button" type="reset" name="reset" value="<?php echo $trl->translate('T_54')?>">
</p>
</form>

